const { v4: uuidv4 } = require('uuid');

module.exports = {
  up: async (queryInterface) => {
    const now = new Date();

    const plans = [
      {
        id: uuidv4(),
        name: '免费版',
        code: 'free',
        description: '适合个人用户和小型团队试用',
        price: 0,
        billing_cycle_code: 'monthly',
        price_monthly: 0,
        price_yearly: 0,
        max_users: 5,
        max_storage: 1073741824, // 1GB
        max_projects: 3,
        support_level: 'basic',
        has_api_access: false,
        has_custom_domain: false,
        has_white_label: false,
        has_sso: false,
        has_advanced_analytics: false,
        is_active: true,
        sort_order: 1,
        created_at: now,
        updated_at: now,
      },
      {
        id: uuidv4(),
        name: '基础版',
        code: 'basic',
        description: '适合小型团队，提供基础功能支持',
        price: 99,
        billing_cycle_code: 'monthly',
        price_monthly: 99,
        price_yearly: 999,
        max_users: 20,
        max_storage: 10737418240, // 10GB
        max_projects: 10,
        support_level: 'basic',
        has_api_access: false,
        has_custom_domain: false,
        has_white_label: false,
        has_sso: false,
        has_advanced_analytics: false,
        is_active: true,
        sort_order: 2,
        created_at: now,
        updated_at: now,
      },
      {
        id: uuidv4(),
        name: '专业版',
        code: 'professional',
        description: '适合中型企业，提供优先支持和高级功能',
        price: 299,
        billing_cycle_code: 'monthly',
        price_monthly: 299,
        price_yearly: 2999,
        max_users: 100,
        max_storage: 107374182400, // 100GB
        max_projects: 50,
        support_level: 'priority',
        has_api_access: true,
        has_custom_domain: true,
        has_white_label: false,
        has_sso: false,
        has_advanced_analytics: true,
        is_active: true,
        sort_order: 3,
        created_at: now,
        updated_at: now,
      },
      {
        id: uuidv4(),
        name: '企业版',
        code: 'enterprise',
        description: '适合大型企业，提供专属支持和所有高级功能',
        price: 999,
        billing_cycle_code: 'monthly',
        price_monthly: 999,
        price_yearly: 9999,
        max_users: null, // 无限制
        max_storage: null, // 无限制
        max_projects: null, // 无限制
        support_level: 'dedicated',
        has_api_access: true,
        has_custom_domain: true,
        has_white_label: true,
        has_sso: true,
        has_advanced_analytics: true,
        is_active: true,
        sort_order: 4,
        created_at: now,
        updated_at: now,
      },
    ];

    await queryInterface.bulkInsert('plans', plans);
  },

  down: async (queryInterface) => {
    await queryInterface.bulkDelete('plans', null, {});
  },
};

优化